package cn.decorate.service.impl;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.decorate.bean.Department;
import cn.decorate.service.DepartService;

/**
 * 
 * @author 张朝斌 实现部门增删改查操作
 * 
 */

@Transactional
@Service("departService")
public class DepartServiceBean implements DepartService {
	@Resource
	private SessionFactory sessionFactory;

	// 添加部门
	public void save(Department department) {
		sessionFactory.getCurrentSession().persist(department);
	}

	// 查询部门编号
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public Department getDepart(Integer departId) {
		return (Department) sessionFactory.getCurrentSession().get(
				Department.class, departId);
	}

}
